package com.k2data.k2app.controller;

import com.k2data.k2app.response.CommonResultResponse;
import com.k2data.k2app.response.ResponseHelper;
import com.k2data.k2app.service.SysTreeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * Created by k2data on 17-12-11.
 */
@Api
@RestController
@RequestMapping("/systree")
public class SysTreeController {

    private final SysTreeService sysTreeService;

    @Autowired
    public SysTreeController(SysTreeService sysTreeService){
        this.sysTreeService=sysTreeService;
    }

    @ApiOperation(value = "获取组织bom结构")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "userId", required = true, dataType = "Long", paramType = "query")
    })
    @GetMapping(value = "/sys")
    public ResponseEntity<CommonResultResponse> getFileds(@RequestParam(value = "userId") Long userId) throws Exception{
        return ResponseHelper.success(sysTreeService.getTree(userId));
    }


}
